package com.scedu.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/*
微信接口 手工版
 */
@RestController
@RequestMapping("/weixin")
@Slf4j
public class WeixinController {
    @GetMapping(value = "/auth")
    public  void auth(@RequestParam("code") String code){
        log.info("微信授权登录,code={}",code);
        String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx539d1d5b753b15c2&secret=7ca69e44d9ce81a4746e6ff6ced0dc4a&code=" + code + "&grant_type=authorization_code";
        RestTemplate restTemplate=new RestTemplate();
        String response=restTemplate.getForObject(url,String.class);
        log.info("INFO. response={}",response);
    }
}
